package sakila.dal.commondao;

import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;

/**
 * The Class DALConstant contain constants using for data access layer.
 */
public final class DALConstant
{

	/** The Constant JDBC_DRIVER. */
	public static final int JDBC_DRIVER = 0x0000;

	/** The Constant CONNECTION_STRING. */
	public static final int CONNECTION_STRING = 0x0001;

	/** The Constant DATA_USER. */
	public static final int DATA_USER = 0x0002;

	/** The Constant DATA_PASSWORD. */
	public static final int DATA_PASSWORD = 0x0003;

	/** The data access layer configuration map. */
	private static Map<Integer, String> dalConfigMap = new HashMap<Integer, String>();

	/** The bundle configuration. */
	private static ResourceBundle bundleConfig = ResourceBundle
	        .getBundle("sakila.dal.commondao.dataconfig");
	static
	{
		// Configuration data connection
		DALConstant.dalConfigMap.put(DALConstant.JDBC_DRIVER,
		        DALConstant.bundleConfig.getString("JDBC_DRIVER"));

		DALConstant.dalConfigMap.put(DALConstant.CONNECTION_STRING,
		        DALConstant.bundleConfig.getString("CONNECTION_STRING"));

		DALConstant.dalConfigMap.put(DALConstant.DATA_USER,
		        DALConstant.bundleConfig.getString("DATA_USER"));

		DALConstant.dalConfigMap.put(DALConstant.DATA_PASSWORD,
		        DALConstant.bundleConfig.getString("DATA_PASSWORD"));
	}

	/**
	 * Gets the resource text.
	 * 
	 * @param resCode the resource code
	 * @return the resource text
	 */
	public static String getValue(final int resCode)
	{
		final int intResCode = Integer.valueOf(resCode);
		String resText = "";
		if (DALConstant.dalConfigMap.containsKey(intResCode))
		{
			resText = DALConstant.dalConfigMap.get(intResCode);
		}
		return resText;
	}
}
